<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <p>四种自适应布局方式</p>
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      .table_layout {
        width: 100%;
        display: table;
        /* //表格 边框合并 */
        border-collapse: collapse;
        /* border: 1px solid red; */
      }
      .table_layout > .left {
        display: table-cell;
        width: 100px;
        /* height: 100px; */
        background-color: red;
      }
      .table_layout > .right {
        display: table-cell;
        width: 100px;
        /* height: 100px; */
        background-color: red;
      }
      .center {
        display: table-cell;
        background-color: yellow;
      }
      /* --------------------- */
      .grid_layout {
        display: grid;
        /* 转化元素类型 */
        /* display: grid; */
        /* 设置网格的间隙 */
        /* grid-gap: 10px; */
        /* 设置每列的尺寸 */
        /* grid-template-columns: repeat(3, 1fr); */
        /* border: none; */

        grid-template-columns: 100px auto 100px;
        grid-template-rows: 100px;
      }
      /* ----------------------- */
      .position_layout {
        width: 100%;
        position: relative;
        height: 100px;
      }

      .position_layout > .left {
        width: 100px;
        position: absolute;
        /* height: 100px; */
        background-color: red;
        left: 0;
      }
      .position_layout > .center {
        /* width: 100px; */
        position: absolute;
        left: 100px;
        right: 100px;
      }
      .position_layout > .right {
        width: 100px;
        position: absolute;
        right: 0px;
      }
      /* ---------- */
      .float_layout > .left {
        width: 100px;
        height: 100px;
        float: left;
      }
      .float_layout > .center {
        /* width: 100px;
        height: 100px; */
        background-color: blue;
        width: calc(100% - 200px);
        float: left;
      }
      .float_layout > .right {
        width: 100px;
        height: 100px;
        float: right;
      }
    </style>
    <!-- 表格布局自适应 -->
    <section class="table_layout">
      <div class="left">左</div>
      <div class="center">中</div>
      <div class="right">右</div>
    </section>
    <!-- 网格布局 -->
    <section class="grid_layout">
      <div class="left">左</div>
      <div class="center">中</div>
      <div class="right">右</div>
    </section>
    <!-- 定位 -->
    <section class="position_layout">
      <div class="left">左</div>
      <div class="center">中</div>
      <div class="right">右</div>
    </section>
    <!-- float -->
    <section class="float_layout">
      <div class="left">左</div>
      <div class="center">中</div>
      <div class="right">右</div>
    </section>
  </body>
</html>
